<%@page import="org.upt.dcda.db.OrderItemEntity"%>
<%@page import="org.upt.dcda.presentation.OrderInformation"%>
<%@page import="org.upt.dcda.presentation.SessionAttributes"%>
<%@page import="org.upt.dcda.db.UserEntity"%>
<%@page import="org.upt.dcda.db.OrderEntity"%>
<%@page import="java.util.List"%>
<%@ taglib prefix="stripes"
	uri="http://stripes.sourceforge.net/stripes.tld"%>
<%
if (!SessionAttributes.isAdmin(request)) 
{
	response.sendRedirect("index.jsp");
} else {
%>
<stripes:layout-render name="layout/default.jsp"
	pageTitle="Using A Layout">

	<stripes:layout-component name="pageTitle">
	Orders
 	</stripes:layout-component>

	<stripes:layout-component name="html_head">

	</stripes:layout-component>

	<stripes:layout-component name="contents">
<%
	OrderInformation orderInfo = new OrderInformation();
	List<OrderEntity> orders = orderInfo.viewAllOrders(request, response);
	
	for(OrderEntity oe : orders) {
%>
		<hr></hr>
		<p><%= oe.getUser().getUserEmail() %></p>
		<%
		for(OrderItemEntity oie : oe.getOrderitems()) {
%>
		<p><%= oie.getBook().getBookTitle() %></p>
		<p><%= oie.getOrderitemsQuantity() %></p>
		<%
		}
	}
%>
	</stripes:layout-component>

</stripes:layout-render>
<%
}
%>